package com.heima.kafka.listener;

import cn.hutool.json.JSONUtil;
import com.heima.kafka.dto.UserDto;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

@Component
public class HelloListener {
    @KafkaListener(topics = "itcast-topic")
    public void helloListener(String msg){
        System.out.println("接收到kafka的消息了，msg = " + msg);
    }

    @KafkaListener(topics = "itcast-topic-user")
    public void userListener(String msg){
        System.out.println("接收到kafka的消息了，msg = " + msg);
        UserDto userDto = JSONUtil.toBean(msg, UserDto.class);
        System.out.println("接收到kafka的消息了，userDto = " + userDto);
    }


}
